home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
vsc92nov.zip
/
Boolean.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-02
|
2KB
|
94 lines
/*
* Boolean.c -- Implementation of Scheme Booleans (and ())
*
* (C) m.b (Matthias Blume), Mar 1992, HUB/Ger
*/
# ident "@(#)Boolean.c (C) M.Blume, Humboldt-Uni Berlin, 1.1"
# include <stdio.h>
# include "storext.h"
# include "Boolean.h"
# include "type.h"
# include "identifier.h"
# include "except.h"
static
void dump (void *vbool, FILE *file)
{
putc ((ScmBoolean *)vbool == &ScmTrue
? 't'
: (ScmBoolean *)vbool == &ScmFalse
? 'f'
: (ScmBoolean *)vbool == &ScmEof
? 'e'
: 'n',
file);
}
static
void *restore_init (FILE *file)
{
switch (getc (file)) {
case 't':
return &ScmTrue;
case 'f':
return &ScmFalse;
case 'n':
return &ScmNil;
case 'e':
return &ScmEof;
default: /* including EOF */
fatal ("bad dump file format (Boolean)");
break;
}
/*NOTREACHED*/
}
static
void display (void *vbool, putc_proc pp, void *cd)
{
if ((ScmBoolean *) vbool == &ScmNil)
putc_string ("()", pp, cd);
else if ((ScmBoolean *) vbool == &ScmEof)
putc_string ("#<End-of-File>", pp, cd);
else {
(* pp) ('#', cd);
(* pp) (((ScmBoolean *) vbool == &ScmTrue) ? 't' : 'f', cd);
}
}
static
struct scheme_od_extension ext = {
display,
display,
NULL, NULL, /* Booleans are equal only if they coincide */
};
OD_VECTOR (ScmBoolean_od_vector,
0, /* these are fixed objects, there can be only one */
NULL,
do_nothing_on_subs,
BOOLEAN_IDENTIFIER,
dump, restore_init, NULL,
NULL, NULL, NULL,
&ext
);
ScmBoolean ScmTrue = {
ScmType (Boolean)
};
ScmBoolean ScmFalse = {
ScmType (Boolean)
};
ScmBoolean ScmNil = {
ScmType (Boolean)
};
ScmBoolean ScmEof = {
ScmType (Boolean)
};